package com.falm.picturebackend.entity.convert;

import com.falm.picturebackend.entity.BO.StorageInfoBO;
import com.falm.picturebackend.entity.DO.StorageInfoDO;
import com.falm.picturebackend.entity.VO.StorageInfoVO;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Administrator
 */
public class StorageInfoConvert {

    public static StorageInfoBO do2BO(StorageInfoDO storageInfoDO) {
        if (storageInfoDO == null) {
            return null;
        }
        StorageInfoBO storageInfoBO = new StorageInfoBO();
        storageInfoBO.setId(storageInfoDO.getId());
        storageInfoBO.setStorageType(storageInfoDO.getStorageType());
        storageInfoBO.setEndpoint(storageInfoDO.getEndpoint());
        storageInfoBO.setBucketName(storageInfoDO.getBucketName());
        storageInfoBO.setRegion(storageInfoDO.getRegion());
        storageInfoBO.setIsDefault(storageInfoDO.getIsDefault());
        storageInfoBO.setCreateTime(storageInfoDO.getCreateTime());
        storageInfoBO.setUpdateTime(storageInfoDO.getUpdateTime());
        return storageInfoBO;
    }

    public static StorageInfoDO bo2DO(StorageInfoBO storageInfoBO) {
        if (storageInfoBO == null) {
            return null;
        }
        StorageInfoDO storageInfoDO = new StorageInfoDO();
        storageInfoDO.setId(storageInfoBO.getId());
        storageInfoDO.setStorageType(storageInfoBO.getStorageType());
        storageInfoDO.setEndpoint(storageInfoBO.getEndpoint());
        storageInfoDO.setBucketName(storageInfoBO.getBucketName());
        storageInfoDO.setRegion(storageInfoBO.getRegion());
        storageInfoDO.setIsDefault(storageInfoBO.getIsDefault());
        storageInfoDO.setCreateTime(storageInfoBO.getCreateTime());
        storageInfoDO.setUpdateTime(storageInfoBO.getUpdateTime());
        return storageInfoDO;
    }

    public static StorageInfoVO bo2VO(StorageInfoBO storageInfoBO) {
        if (storageInfoBO == null) {
            return null;
        }
        StorageInfoVO storageInfoVO = new StorageInfoVO();
        storageInfoVO.setId(storageInfoBO.getId());
        storageInfoVO.setStorageType(storageInfoBO.getStorageType());
        storageInfoVO.setEndpoint(storageInfoBO.getEndpoint());
        storageInfoVO.setBucketName(storageInfoBO.getBucketName());
        storageInfoVO.setRegion(storageInfoBO.getRegion());
        storageInfoVO.setIsDefault(storageInfoBO.getIsDefault());
        storageInfoVO.setCreateTime(storageInfoBO.getCreateTime());
        storageInfoVO.setUpdateTime(storageInfoBO.getUpdateTime());
        return storageInfoVO;
    }

    public static List<StorageInfoBO> do2BOList(List<StorageInfoDO> storageInfoDOList) {
        return storageInfoDOList.stream().map(StorageInfoConvert::do2BO).collect(Collectors.toList());
    }
}